package com.vader.boot.beanPostProcessorTest;

import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.context.annotation.AnnotationBeanNameGenerator;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ConfigurationClassPostProcessor;
import org.springframework.context.support.GenericApplicationContext;
import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.core.type.MethodMetadata;
import org.springframework.core.type.classreading.CachingMetadataReaderFactory;
import org.springframework.core.type.classreading.MetadataReader;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;

/**
 * @author Vader
 * @date 2022/5/19
 **/
@Slf4j
public class TestApplicationContext {
    public static void main(String[] args) throws IOException {
        GenericApplicationContext genericApplicationContext = new GenericApplicationContext();
        genericApplicationContext.registerBean("config", Config.class);
        genericApplicationContext.registerBean(ComponentScanPostProcessor.class);
//        genericApplicationContext.registerBean(BeanScanPostProcessor.class);
//        genericApplicationContext.registerBean(MapperPostProcessor.class);

//        genericApplicationContext.registerBean(ConfigurationClassPostProcessor.class);
//        genericApplicationContext.registerBean(MapperScannerConfigurer.class, beanDefinition -> {
//            beanDefinition.getPropertyValues().add("basePackage", "com.vader.boot.beanPostProcessorTest.mapper");
//        });
        genericApplicationContext.refresh();

        for (String beanDefinitionName : genericApplicationContext.getBeanDefinitionNames()) {
            log.info("beanName:{}", beanDefinitionName);
        }

        genericApplicationContext.close();
    }
}

